import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import { resolve } from 'path';
import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
import { viteMockServe } from 'vite-plugin-mock';

// https://vitejs.dev/config/
export default defineConfig({
    plugins: [vue(),
        viteMockServe({
            mockPath: './src/mock',
        }),
        AutoImport({
            resolvers: [ElementPlusResolver()],
        }),
        Components({
            resolvers: [ElementPlusResolver()],
        }),
    ],
    resolve: {
        alias: {
            '@': resolve(__dirname, './src'),
            '@views': resolve(__dirname, './src/views'),
            '@assets': resolve(__dirname, './src/assets'),
            '@api': resolve(__dirname, './src/api'),
            '@config': resolve(__dirname, './src/config'),
            '@components': resolve(__dirname, './src/components'),
            '@v1': resolve(__dirname, './src/components/v1'),
            '@auth': resolve(__dirname, './src/auth'),
            '@util': resolve(__dirname, './src/util'),
            '@mixins': resolve(__dirname, './src/mixin'),
            '@base-comp': resolve(__dirname,
                './src/components/base-component',
            ),
            '@dataset-adapter': resolve(__dirname, './src/dataset-adapter'),
            '@data': resolve(__dirname, './src/data'),
            '@dsm': resolve(__dirname, './src/data-source-manager'),
            '@router': resolve(__dirname, './src/router'),
            '@store': resolve(__dirname, './src/store'),
            '@filter': resolve(__dirname, './src/filter'),
            '@mock': resolve(__dirname, './src/mock'),
            '@processor': resolve(__dirname, './src/processor'),
            '@event': resolve(__dirname, './src/event'),
            '@types': resolve(__dirname, './src/types'),
        },
    },
    base: './',
    server: {
        port: 4000,
        open: true,
        cors: true,
    },
    css: {
        preprocessorOptions: {
            scss: {
                additionalData: '@import "./src/assets/scss/common.scss";',
            },
        },
    },
});
